# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=gdnsd
pkgver=3.8.1
pkgrel=1
pkgdesc="Geographic Authoritative DNS server"
url="https://github.com/gdnsd/gdnsd/"
arch="all"
license="GPL-3.0-or-later"
makedepends="
	autoconf
	automake
	libcap-dev
	libev-dev
	libmaxminddb-dev
	libsodium-dev
	libtool
	ragel
	userspace-rcu-dev
	"
checkdepends="
	perl
	perl-libwww
	perl-socket6
	perl-io-socket-inet6
	perl-http-daemon
	perl-test-harness
	perl-test-harness-utils
	"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/gdnsd/gdnsd/releases/download/v$pkgver/gdnsd-$pkgver.tar.xz
	gdnsd.initd
	"
options="!check" # missing perl modules for tests

# secfixes:
#   2.4.3-r0:
#     - CVE-2019-13952

prepare() {
	default_prepare
	autoreconf -vif
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--enable-fast-install
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/gdnsd.initd "$pkgdir"/etc/init.d/gdnsd
}

sha512sums="
28f276dd31d7dbd97b76c6289303cc43850a9e7ab8b4a754d728a3053297ca8885af514204e27743819278c2e2fea7526877932ae93a79939bec4d398b77343c  gdnsd-3.8.1.tar.xz
7e66f9d3dab3a36334d47740f12ee7f3ffd363d416bd1fcca4b339db8ba858419555751786247ffc4e5faf68c6b5fa87b84c04ffa25133a17b186bdf83c365b9  gdnsd.initd
"
